package com.system.post.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.system.employee.entity.Employee;
import com.system.part.entity.Part;

@Entity
@Table(name="t_post")
public class Post {
	private Long postId;
	private String postName;
	private Long basicSalary;
	private Long  requiredNum;
	private Long  actualNum;
	private List<Employee> empLists=new ArrayList<Employee>();//一对多员工
	private Part part;
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getPostId() {
		return postId;
	}
	public String getPostName() {
		return postName;
	}
	
	public Long getBasicSalary() {
		return basicSalary;
	}
	public Long getRequiredNum() {
		return requiredNum;
	}
	@JsonIgnore
	@OneToMany(mappedBy="post")
	public List<Employee> getEmpLists() {
		return empLists;
	}
	@ManyToOne
	@JoinColumn
	public Part getPart() {
		return part;
	}
	
	public Long getActualNum() {
		this.actualNum=(long) empLists.size();
		return actualNum;
	}
	//...............................set方法................................
	
	public void setPart(Part part) {
		this.part = part;
	}
	public void setActualNum(Long actualNum) {
		this.actualNum = actualNum;
	}
	public void setEmpLists(List<Employee> empLists) {
		this.empLists = empLists;
	}
	public void setBasicSalary(Long basicSalary) {
		this.basicSalary = basicSalary;
	}
	public void setRequiredNum(Long requiredNum) {
		this.requiredNum = requiredNum;
	}
	public void setPostId(Long postId) {
		this.postId = postId;
	}
	public void setPostName(String postName) {
		this.postName = postName;
	}
	
	

}
